package com.dlc.yunguang.adapter;

import android.content.Context;
import android.view.View;
import com.dlc.commonlibrary.utils.TimeFormats;
import com.dlc.yunguang.net.bean.OrderBean;
import com.dlc.yunguang.R;
import com.holenzhou.pullrecyclerview.BaseRecyclerAdapter;
import com.holenzhou.pullrecyclerview.BaseViewHolder;
import java.util.List;

/**
 * Created by Administrator on 2017/7/20 0020.
 */

public class OrderAdapter extends BaseRecyclerAdapter<OrderBean.DataBean.ListBean> {
    private OnItemClickListener onItemClickListener;
    int type;
    public OrderAdapter(Context context, int layoutResId, List<OrderBean.DataBean.ListBean> data,int type) {
        super(context, layoutResId, data);
        this.type=type;
    }

    @Override
    protected void convert(BaseViewHolder holder, final OrderBean.DataBean.ListBean item, final int position) {
        if(type==0){
            holder.setText(R.id.send_wash_code_tv,"送洗订单编号");
            holder.setText(R.id.send_wash_time_tv,"送洗时间");
        }else {
            holder.setText(R.id.send_wash_code_tv,"送货订单编号");
            holder.setText(R.id.send_wash_time_tv,"送货时间");
        }
        holder.setText(R.id.tv_amount,item.orderno);
        holder.setText(R.id.tv_num,item.nums);
        holder.setText(R.id.tv_hotel,item.hotel+item.office);
        if (type == 0 || type == 1) {
            if (Integer.parseInt(item.receivetime) == 0) {
                holder.setText(R.id.tv_where, "尚未接收");
            } else {
                holder.setText(R.id.tv_where, TimeFormats.formatDateTimeSecend((long) Integer.parseInt(item.receivetime) * 1000));
            }
        }
        if (type == 3) {//这是回收单
            if (Integer.parseInt(item.divideTime) == 0) {
                holder.setText(R.id.tv_where, "尚未接收");
            } else {
                holder.setText(R.id.tv_where,  TimeFormats.formatDateTimeSecend((long) Integer.parseInt(item.divideTime) * 1000));
            }
        }
        holder.setOnClickListener(R.id.order_item, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onItemClickListener.onClick(position,item.id);
            }
        });


    }


   public interface OnItemClickListener {
       void onClick(int position, String id);
   }
    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener=onItemClickListener;

    }
}
